import request from './request'

// 美容师接口定义
export interface Beautician {
  id?: number
  name: string
  position: string
  experience: number
  specialty?: string
  imageUrl?: string
  phone?: string
  email?: string
  status: 1 | 0
  createdAt?: string
  updatedAt?: string
}

// 美容师排班接口定义
export interface BeauticianSchedule {
  id?: number
  beauticianId: number
  weekDay: number
  startTime: string
  endTime: string
  maxAppointments: number
  currentAppointments: number
  status: 1 | 0 | 2
  notes?: string
  createdAt?: string
  updatedAt?: string
}

// 获取美容师列表（分页）
export const getBeauticians = (params: {
  page?: number
  pageSize?: number
  name?: string
  position?: string
  status?: number
}) => {
  return request({
    url: '/beautician/page',
    method: 'post',
    data: params
  })
}

// beauticianList
export const getBeauticianList = () => {
  return request({
    url: '/beautician/list',
    method: 'get'
  })
}

// 获取单个美容师详情
export const getBeautician = (id: number) => {
  return request({
    url: `/beautician/${id}`,
    method: 'get'
  })
}

// 添加美容师
export const createBeautician = (data: Partial<Beautician>) => {
  return request({
    url: '/beautician/add',
    method: 'post',
    data
  })
}

// 更新美容师信息
export const updateBeautician = (data: Partial<Beautician>) => {
  return request({
    url: `/beautician/update`,
    method: 'post',
    data
  })
}

// 删除美容师
export const deleteBeautician = (id: number) => {
  return request({
    url: `/beautician/${id}`,
    method: 'delete'
  })
}

// 获取所有在职美容师
export const getActiveBeauticians = () => {
  return request({
    url: '/beautician/active',
    method: 'get'
  })
}

// 获取美容师关联的项目
export const getBeauticianProjects = (id: number) => {
  return request({
    url: `/beautician/project`,
    method: 'post',
    data: {
      id
    }
  })
}

// 更新美容师关联的项目
export const updateBeauticianProjects = (beauticianId: number, projectIds: number[]) => {
  return request({
    url: `/beautician/${beauticianId}/projects`,
    method: 'put',
    data: { projectIds }
  })
}

// 获取美容师排班列表（分页）
export const getSchedules = (params: {
  page?: number
  pageSize?: number
  beauticianId?: string
  weekDay?: string
  status?: string
}) => {
  return request({
    url: '/beauticianSchedule/page',
    method: 'post',
    data: params
  })
}

// 获取单个排班详情
export const getSchedule = (id: number) => {
  return request({
    url: `/beautician/schedule/${id}`,
    method: 'get'
  })
}

// 添加排班
export const createSchedule = (data: Partial<BeauticianSchedule>) => {
  return request({
    url: '/beautician/schedule/add',
    method: 'post',
    data
  })
}

// 更新排班信息
export const updateSchedule = (data: Partial<BeauticianSchedule>) => {
  return request({
    url: `/beauticianSchedule/update`,
    method: 'post',
    data
  })
}

// 删除排班
export const deleteSchedule = (id: number) => {
  return request({
    url: `/beautician/schedule/${id}`,
    method: 'delete'
  })
}